package com.demo.burt.config;

import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author luowei1
 * @since 2019/5/15 13:09
 */
@Configuration
public class BurtDruidDataSourceConfig {

    /**
     * 注册druid数据源统计servlet， 用于监控数据源页面
     * <p>
     * 访问地址：http://ip:port/druid/index.html
     *
     * @return
     */
    @Bean(name = "druidServlet")
    @ConditionalOnMissingBean(name = "druidServlet")
    public ServletRegistrationBean registerDruidStatServlet() {
        return new ServletRegistrationBean(new com.alibaba.druid.support.http.StatViewServlet(), "/druid/*");
    }

    //    @Bean
    //    public WallFilter wallFilter() {
    //        WallFilter wallFilter = new WallFilter();
    //        wallFilter.setConfig(wallConfig());
    //        return wallFilter;
    //    }
    //
    //    @Bean
    //    public WallConfig wallConfig() {
    //        WallConfig wallConfig = new WallConfig();
    //        wallConfig.setMultiStatementAllow(true);//允许一次执行多条语句
    //        //        wallConfig.setNoneBaseStatementAllow(true);//允许一次执行多条语句
    //        wallConfig.setSelectLimit(3);
    //        return wallConfig;
    //    }
}
